import { createElement, useEffect, useState } from 'rax';
import { getSearchParams } from 'rax-app';
import View from 'rax-view';
import NavBar from '@/components/NavBar';
import './index.css';

const WebView = () => {
  const [titleBarHeight, setTitleBarHeight] = useState(0);
  const [url, setUrl] = useState('');
  const [name, setName] = useState('');

  useEffect(() => {
    let params = getSearchParams();
    setUrl(params.url)
    setName(params.name)
    my.getSystemInfo({
      success: (res) => {
        let height = res.titleBarHeight + res.statusBarHeight
        setTitleBarHeight(height)
      }
    });
  }, [])
  
  return (
    <View className='mine_container'>
      <NavBar 
        title={name}
        onClick={()=>{doBack()}}
      />
      <View
        className='mine_section'
        style={{
          paddingTop: `${titleBarHeight}px`
        }}
      >
        <web-view src={url}></web-view>
      </View>
    </View>
  )
}
export default WebView;
